@interface XMLNode : NSObject
{
    XMLNode *parent;
    NSMutableArray *children;
}

@property (nonatomic, assign) XMLNode *parent;
@property (nonatomic, retain) NSMutableArray *children;

- (id)initWithParent:(XMLNode *)p;
// For each (key, value) in the dictionary XMLInternalNode with such key is
// created. If value is a dictionary, children are added to that node
// recursively using this method. Otherwise, XMLLeafNode is added with a value
// of [NSString stringWithFormat:@"%@", value]. The caller must ensure that key
// is a NSString and value is appropriate for the above format string.
- (void)addChildrenFromDictionary:(NSDictionary *)dict;
- (NSString *)generateXML;
// Descends down the tree according to path specified in a query of the form:
// "NodeKey/SubNodeKey/SubSubNodeKey". At each level the first child with
// a given key is chosen (additionally, * compares equal to every key). If the
// query contains trailing slash /, the first leaf is selected at the end.
// Returns the final node or nil if such path does not exist.
- (XMLNode *)queryNode:(NSString *)query;
// Same as -queryNode:(NSString*), but query is an array of node keys (with the
// last one possibly empty) and querying begins from given index and ends at
// given index.
- (XMLNode *)queryNode:(NSArray *)query queryStartsAt:(NSInteger)pos
    queryEndsAt:(NSInteger)end;
// Descends down the tree using -queryNode: for the given query without the last
// hop. If such path does not exist, returns nil. Otherwise returns an array
// (possibly empty) with all nodes matching the last hop.
- (NSArray *)queryNodes:(NSString *)query;

@end
